package com.letoken.platform.pub.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;

import java.util.HashMap;
import java.util.Map;

/**
 * 排序定义枚举
 * @author wyl
 */
public enum LetokenTokenTypeEnum {

    /**
     * 代币
     */
    TEST(0, "****"),
    USDT(1, "USDT"),
    LET(2, "USDT"),
    CAPA(3, "CAPA"),
    CAP(4, "CAP"),
    LP(5, "CAP/USDT-LP"),


//    USDT_TEST(3, "USDT-TEST"),
    ;
    @EnumValue
    private final Integer id;
    @JsonValue
    private final String name;

    private static Map<String, LetokenTokenTypeEnum> pool = new HashMap<>();

    public static final Map<String, Integer> nameIdMap = new HashMap<>();
    public static final Map<Integer, String> idNameMap = new HashMap<>();

    static {
        for (LetokenTokenTypeEnum value : LetokenTokenTypeEnum.values()) {
            nameIdMap.put(value.name, value.id);
            idNameMap.put(value.id, value.name);
        }
    }




    LetokenTokenTypeEnum(Integer id, String name) {
        this.id = id;
        this.name = name;
    }

    public static LetokenTokenTypeEnum valueOf(int id) {
        return pool.get(String.valueOf(id));
    }

    public Integer getId() {
        return this.id;
    }

    public String getName() {
        return name;
    }

    public static boolean isSupport(Integer val) {
        for (LetokenTokenTypeEnum openState : values()) {
            if (openState.getId().equals(val)) {
                return true;
            }
        }
        return false;
    }

    public static String getName(String val) {
        for (LetokenTokenTypeEnum openState : values()) {
            if (openState.getId().equals(val)) {
                return openState.getName();
            }
        }
        return "";
    }
    public static String getName(Integer id) {
        LetokenTokenTypeEnum[] letokenTokenTypeEnums = values();
        for (LetokenTokenTypeEnum letokenTokenTypeEnum : letokenTokenTypeEnums) {
            if (letokenTokenTypeEnum.getId().equals(id)) {
                return letokenTokenTypeEnum.getName();
            }
        }
        return null;
    }

    public static void main(String[] args) {
        System.out.println(LetokenTokenTypeEnum.getName(1));
    }

}
